IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[get_yue]') AND type in (N'FN', N'IF', N'TF', N'FS', N'FT'))
  DROP FUNCTION [dbo].[get_yue]

SET ANSI_NULLS OFF
GO

SET QUOTED_IDENTIFIER ON
GO
CREATE FUNCTION get_yue(@a INT,@b INT)
RETURNS INT
AS 
BEGIN
 DECLARE @c INT
 IF @b=0
 RETURN 1
 WHILE @a<>0 
 BEGIN
 SET @c=@a % @b
 IF @c=0
 RETURN @b;
 SET @a=@b
 SET @b=@c 	
 END
 RETURN 1
END
